#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>

#define FILE_NAME "log.txt"


// 每个宏所对应的数值，只有1个比特位为1，彼此位置不重叠

//// 库中的写法
//#define ONE 0x1
//#define TWO 0x2
//#define THREE 0x4
//#define FOUR 0x8
//
// 开源大佬的写法
#define ONE (1<<0)
#define TWO (1<<1)
#define THREE (1<<2)
#define FOUR (1<<3)


void show(int flags)
{
  if(flags & ONE) printf("one\n");
  if(flags & TWO) printf("two\n");
  if(flags & THREE) printf("three\n");
  if(flags & FOUR) printf("four\n");
}
int main()
{
  show(ONE);
  printf("-----------------------------\n");
  show(TWO);
  printf("-----------------------------\n");
  show(ONE | TWO);
  printf("-----------------------------\n");
  show(ONE | TWO | THREE );
  printf("-----------------------------\n");
  show(ONE | TWO | THREE | FOUR);

//  umask(0);
//  FILE *fp  = fopen(FILE_NAME,"w");
//  if(NULL == fp)
//  {
//    perror("fopen");
//    return 1;
//  }
//

//  char buffer[64];
//  while(fgets(buffer,(sizeof buffer )-1,fp)!=NULL)
//  {
//    buffer[strlen(buffer)-1] = 0;
//    puts(buffer);
//  }
//

  //int cnt = 5;
  //while(cnt)
  //{
  //  fprintf(fp,"%s:%d\n","hello bit",cnt--);
  //}
//  int ch;
//  while((ch=getc(fp))!=EOF)
//  {
//    putchar(ch);
//  }
//  fputs("你好啊！！！",fp);
//  fclose(fp);
  return 0;
}



